package com.kaifamiao.month05.day06;

public class EatThread extends Thread {

    private final Cook cook;

    public EatThread(Cook cook, String name) {
        super(name);
        this.cook = cook;
    }

    @Override
    public void run() {
        while (true) {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            cook.eat();
        }
    }
}
